package com.expdatacloud.controller.history;

import com.expdatacloud.dto.ApiResponse;
import com.expdatacloud.entity.IqcDetectionHistory;
import com.expdatacloud.service.IqcDetectionHistoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author jie
 * @date 2019/11/20 -16:09
 */
@Controller
@RequestMapping("/iqcDetectionHistory")
public class IqcDetectionHistoryController {

    @Autowired
    private IqcDetectionHistoryService iqcDetectionHistoryService;

    @GetMapping("/list")
    @ResponseBody
    public ApiResponse list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit,
                            IqcDetectionHistory iqcDetectionHistory) {
        PageHelper.startPage(page, limit);
        PageInfo<IqcDetectionHistory> pageInfo = new PageInfo<>(iqcDetectionHistoryService.list(iqcDetectionHistory));
        return ApiResponse.ok(pageInfo.getTotal(), pageInfo.getList());
    }
}
